package com.ycy;

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
import org.bson.Document;
import org.junit.Test;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.GroupOperation;

public class AggDemo {

  static MongoCollection<Document> coll;
  static MongoClient mongoClient = null;

  @Test
  public void test() {
//    Aggregation.group("a","b","c","d","e").count().as("f")

//    coll
    Aggregation agg = Aggregation.newAggregation(
            Aggregation.group("vars.nrOfInstances", "procDefName", "appName").count().as("count")
                    .sum("vars.ASSIGNEE_aaaaa_ID").as("total")//分组字段
    );

    GroupOperation as = Aggregation.group("vars.nrOfInstances", "procDefName", "appName").count().as("count")
            .sum("vars.ASSIGNEE_aaaaa_ID").as("total")
            .avg("1").as("2");

    System.out.println();
  }

}
